import http from '@/http';

// 约束：G:\giteeOmss\omss\omss\src\types\user.d.ts
export const userListApi = (params:IUserListParams):RES<IUserListModel> => 
    http.get('/user/userlist',{params});

//更改状态的接口   id:number,status:number 只是局部  不是公共的所以放到这里 直接约束
export const changeStatusApi = (id:number,status:number):RES<number> =>   //RES<number>约束的是返回的数据
    http.post(`/user/changeStatus/${id}?status=${status}`);


//添加用户的接口
export const addUserApi= (params:IUserModel):RES<IUserDataModel>=> 
    http.post('/user/addUser',params); //这里添加的参数是IUserModel  参数根据约束填写 不是必填字段得有 数据返回可以为空

export const getUserByIdApi = (id:number):RES<IUserListModel> => 
    http.get(`/user/getUserById/${id}`);

//更新用户的接口
export const updateUserApi = (params:IUserModel):RES<IUserDataModel>=> 
    http.post(`/user/updateUser/${params.id}`,params);


//获取角色的接口
export const getRoleListApi = (params:IRoleListParams):RES<IRoleDataModel> => 
    http.get(`/user/role/list`,{params});
//根据用户id获取用户的角色
export const getRoleByUserIdApi = (userid:number):RES<IRoleDataModel> => 
    http.get(`/user/role/list?${userid}`);
//修改用户的角色user/update_roles/
export const updateRoleByUserIdApi = (userid:number,roleids:number[]):RES<IRoleDataModel> => 
    http.post(`/user/role/update_roles?userid=${userid}&rolelist=${roleids.join(",")}`); //rolelist=1,2,3 传递字符串过去

